package rp.group;

import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.scoreboard.Team;
import utils.COLOR;
import utils.UTIL;

public class LSNGroup implements Listener {
    @EventHandler
    public void onLogin(PlayerJoinEvent e) {
        Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
        Player player = e.getPlayer();
        if(scoreboard.getEntryTeam(player.getName())==null){
            Team team = scoreboard.registerNewTeam(player.getName());
            team.setDisplayName(player.getName());
            team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.FOR_OTHER_TEAMS);
            team.setOption(Team.Option.COLLISION_RULE, Team.OptionStatus.FOR_OWN_TEAM);
            //team.setOption(Team.Option.DEATH_MESSAGE_VISIBILITY, Team.OptionStatus.FOR_OTHER_TEAMS);
            team.setCanSeeFriendlyInvisibles(true);
            team.setAllowFriendlyFire(false);
            team.addEntry(player.getName());

            //team.setColor(ChatColor.RESET);
            //team.setPrefix("");
            //team.setSuffix("");

            player.setScoreboard(scoreboard);
        }
    }

}
